//
//  UIBarButtonItem + extension.swift
//  weibo1990
//
//  Created by 曹晓龙 on 15/10/24.
//  Copyright © 2015年 曹晓龙. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    ///  便利构造函数
    ///
    ///  - parameter imageName:  图片名
    ///  - parameter target:     监听对象
    ///  - parameter actionName: 方法名
    ///
    ///  - returns: UIBarButtonItem
    convenience init (imageName:String, target:AnyObject?, actionName:String?){
        
        let btn:UIButton = UIButton(imageName: imageName, backImageName: nil)
        
        if let actionName = actionName{
            
            btn.addTarget(target , action: Selector(actionName), forControlEvents: UIControlEvents.TouchUpInside)
        }
        
        
        self.init(customView : btn)
        
    }
}
